package com.zhanghu.backendZray.converter;

import com.zhanghu.backendZray.pojo.entity.Menu;
import com.zhanghu.backendZray.pojo.request.menu.MenuRequest;
import com.zhanghu.backendZray.pojo.vo.MenuVo;
import org.springframework.stereotype.Component;

/**
 * @author ZhangDong
 * @date 2024/7/20 11:39
 */
@Component
public class MenuConverter extends Converter<MenuRequest, Menu, MenuVo> {
    public MenuConverter() {
        super(MenuConverter::request2Menu, MenuConverter::menu2Vo);
    }

    private static Menu request2Menu(MenuRequest request) {
        Menu menu = new Menu();
        menu.setId(request.getId());
        menu.setName(request.getName());
        menu.setEnName(request.getEnName());
        menu.setParentId(request.getParentId());
        return menu;
    }

    private static MenuVo menu2Vo(Menu entity) {
        MenuVo vo = new MenuVo();
        vo.setId(entity.getId());
        vo.setName(entity.getName());
        vo.setEnName(entity.getEnName());
        vo.setParentId(entity.getParentId());
        return vo;
    }

}
